package com.sirui.jpa.model;

import com.sirui.spider.kuai.entity.CommonConstants;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.MutablePropertyValues;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 用户实体(此处注意引用的注解包为javax.persistence*下面的)
 * 创建者
 * 创建时间	2017年7月25日
 */
@Entity
@Table(name = "t_jpa_user")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class JpaUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(generator = CommonConstants.HIBERNATE_GENERATOR_UUID)
    @org.hibernate.annotations.GenericGenerator(name = CommonConstants.HIBERNATE_GENERATOR_UUID, strategy = CommonConstants.HIBERNATE_STRATEGY_UUID)
    @Column(name = "ID", length = CommonConstants.HIBERNATE_UUID_LENGTH, unique = true)
    private String id;
    @Column(nullable = false, name = "name")
    private String name;
    @Column(nullable = false, name = "age")
    private Integer age;
    @Column(nullable = false, name = "address")
    private String address;
    @Column(nullable = true, name = "birthdate")
    private Date birthdate;

    @Lob
    @Column(nullable = true, name = "mutable_property_values")
    private MutablePropertyValues mutablePropertyValues;

    @Column(name = "school_class", length = 255)
    private Class schoolClass;

    @Lob
    @Column(name = "remark")
    private String remark;

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", address='" + address + '\'' +
                ", birthdate=" + birthdate +
                '}';
    }
}
